
package com.yixiu.modules.xss;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * XSS过滤器
通过继承Filter接口，实现xss过滤器
 */
public class XssFilter implements Filter {


	@Override
	public void init(javax.servlet.FilterConfig var1) throws ServletException {

	}

	/**
	 * 实现过滤器的核心在于实现方法doFilter，
	 * 通过责任链的方式处理请求request
	 * 具体处理过程在类XssHttpServletRequestWrapper中
	 * @param request
	 * @param response
	 * @param chain
	 * @throws IOException
	 * @throws ServletException
	 */
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
		XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
				(HttpServletRequest) request);
		chain.doFilter(xssRequest, response);
	}


	public void destroy() {
	}

}